<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Listar.aspx.cs" Inherits="Listar" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link rel="stylesheet" href="../css/wide.css" type="text/css" media="screen, projection" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="NavigationContent" runat="Server">
    <ul id="main-nav" class="clearfix">
        <li><a href="../Default.aspx">Inicio</a></li>
        <li><a href="Agregar.aspx">Mis Libros</a></li>
        <li>Listar</li>
        <li id="right-tab"><a href="Contacto.aspx">Contacto</a></li>
    </ul>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="BusquedaAvanzada" runat="Server">
    <div id="side-col">
        <div class="side-box-top">
        </div>
        <div class="side-box-middle">
            <a href="BusquedaAvanzada.aspx">
                <img src="/site/images/view-products.jpg" alt="Ver Libros" height="40px" /></a>
        </div>
        <div class="side-box-bottom">
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <span style="color: #ffffff">Cantidad total de libros: </span>
    <asp:Label ID="lblTotalLibros" runat="server" Font-Bold="True" ForeColor="White"
        Text="Label"></asp:Label>&nbsp; <span style="color: #ffffff">Cantidad total de usuarios:</span>
    <asp:Label ID="lblTotalUsuarios" runat="server" Font-Bold="True" ForeColor="White"
        Text="Label"></asp:Label><br />
    <br />
    <table style="width: 403px; height: 100px">
        <tr>
            <td style="width: 236px; height: 15px">
                <span style="color: #ffffff">Libros por usuario</span></td>
            <td style="width: 203px; height: 15px">
                <span style="color: #ffffff">Libros por localidad</span></td>
        </tr>
        <tr>
            <td style="width: 236px" valign="top">
                <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None"
                    PageSize="5" Width="183px">
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <Columns>
                        <asp:BoundField DataField="UserName" HeaderText="Usuario" SortExpression="UserName" />
                        <asp:BoundField DataField="Expr1" HeaderText="Cantidad de libros" ReadOnly="True"
                            SortExpression="Expr1" />
                    </Columns>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:GridView>
            </td>
            <td style="width: 203px" valign="top">
                <asp:GridView ID="GridView3" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    CellPadding="4" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None"
                    PageSize="5" Width="181px">
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <Columns>
                        <asp:BoundField DataField="Localidad" HeaderText="Localidad" ReadOnly="True" SortExpression="Localidad" />
                        <asp:BoundField DataField="Expr1" HeaderText="Cantidad de libros" ReadOnly="True"
                            SortExpression="Expr1" />
                    </Columns>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:GridView>
            </td>
        </tr>
    </table>
    <br />
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:autoGeneratedConnection %>"
        SelectCommand="SELECT        dbo.aspnet_Profile_GetProfile(dbo.aspnet_Users.UserId, 'Localidad', DEFAULT) AS Localidad, COUNT(dbo.tblLibros.Titulo) AS Expr1&#13;&#10;FROM            dbo.aspnet_Users INNER JOIN&#13;&#10;                         dbo.tblLibros ON dbo.aspnet_Users.UserId = dbo.tblLibros.UserId&#13;&#10;GROUP BY dbo.aspnet_Profile_GetProfile(dbo.aspnet_Users.UserId, 'Localidad', DEFAULT)">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:autoGeneratedConnection %>"
        SelectCommand="SELECT DISTINCT aspnet_Users_1.UserName, COUNT(*) AS Expr1&#13;&#10;FROM            aspnet_Profile AS aspnet_Profile_1 INNER JOIN&#13;&#10;                         aspnet_Users AS aspnet_Users_1 ON aspnet_Profile_1.UserId = aspnet_Users_1.UserId INNER JOIN&#13;&#10;                         tblLibros AS tblLibros_1 ON aspnet_Profile_1.UserId = tblLibros_1.UserId&#13;&#10;GROUP BY aspnet_Users_1.UserName">
    </asp:SqlDataSource>
    <br />
    <span style="color: #ffffff">Libros de otros usuarios:</span><br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" PageSize="5" OnPageIndexChanging="gridView_PageIndexChanging" OnSorting="gridView_Sorting" AllowSorting="True"  >
        <Columns>
            <asp:ImageField DataImageUrlField="ImagenLibro" NullImageUrl="~/images/imagen-no-disponible.jpg">
                <ControlStyle BorderStyle="None" Height="90px" Width="65px" />
            </asp:ImageField>
            <asp:TemplateField HeaderText="Titulo" SortExpression="Titulo">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Titulo") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Autor" SortExpression="Autor">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Autor") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Editorial" SortExpression="Editorial">
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Editorial") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ImagenLibro" Visible="False">
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("ImagenLibro") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Disponible" SortExpression="Disponible">
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("Disponible") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Due&#241;o" SortExpression="UserName">
                <ItemTemplate>
                    <asp:Label ID="Label0" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Dueno" Visible="False">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Localidad" SortExpression="PropertyValuesString">
                <ItemTemplate>
                    <asp:Label ID="Label0" runat="server" Text='<%# Bind("PropertyValuesString") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Email" DataFormatString="&lt;a href=mailto:{0}&gt;{0}&lt;/a&gt;" HtmlEncodeFormatString="False"
                HeaderText="Email" SortExpression="Email" />
        </Columns>
        <RowStyle BackColor="White" />
        <HeaderStyle BackColor="#E0E0E0" ForeColor="Black" />
        <AlternatingRowStyle BackColor="WhiteSmoke" />
    </asp:GridView>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Destacados" runat="Server">
</asp:Content>

